#ifndef POINT_SETTING_WIDGET_H
#define POINT_SETTING_WIDGET_H

#include <QWidget>
#include "search_tree_widget.h"
#include "point_add_dialog.h"
#include "state_info.h"
class DealerHandler;

namespace Ui
{
    class PointSettingWidget;
}

class PointSettingWidget : public QWidget
{
    Q_OBJECT

public:
    explicit PointSettingWidget(QWidget *parent = nullptr);
    ~PointSettingWidget();

    /**
     * @brief 设置搜索树形控件
     * @details 设置搜索树形控件，并连接搜索树形控件的点击信号
     * @param search_tree_widget 搜索树形控件
     */
    void setSearchTreeWidget(SearchTreeWidget *search_tree_widget);

protected:
    /**
     * 显示事件 
     */
    void showEvent(QShowEvent *event) override;
    /**
     * 隐藏事件
     */
    void hideEvent(QHideEvent *event) override;

private slots:
    /**
     * 搜索树形控件点击事件
     */
    void onSearchTreeWidgetItemClicked(StateInfo state_info);
    /**
     * 保存协议按钮点击事件
     */
    void onSaveProtocalBtnClicked();
    /**
     * 新增按钮点击事件
     */
    void onAddButtonClicked();
    /**
     * 删除按钮点击事件
     */
    void onDeleteButtonClicked();

    /**
     * 下装按钮点击事件
     */
    void onSettingButtonClicked();

    /**
     * 网络响应事件
     */
    void onNetworkResponse(const QString &method, const QString &body);

    /**
     * 渲染遥信点表
     * @param station_id 场站ID
     */
    void renderYxTable(int64_t station_id);

    /**
     * 渲染遥控点表
     */
    void renderYkTable(int64_t station_id);

    /**
     * 渲染遥测点表
     */
    void renderYcTable(int64_t station_id);
    
    /**
     * 渲染遥调点表
     */
    void renderYtTable(int64_t station_id);

    /**
     * 手风琴组件变化事件
     */
    void onToolBoxChanged(int index);

private:
    Ui::PointSettingWidget *ui_;
    SearchTreeWidget *search_tree_widget_;

    StateInfo state_info_;

    StateInfo::PointSetting point_setting_;

    DealerHandler *dealer_handler_;
};

#endif // POINT_SETTING_WIDGET_H
